home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-22 | 1.6 KB | 75 lines | [TEXT/MPS ] |
- /*
- # File: TempRef.th
- #
- # Contains: Internal header for use by TempObj.h
- #
- # Owned by: Jens Alfke
- #
- # Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- #
- #
- # In Progress:
- #
- */
-
- // This header is a utility used by TempObj.h. Do not include it directly unless you
- // really know what you're doing -- see the Tech Note "Temporary Objects/References".
-
- #ifndef SOM_ODDocument_xh
- #include <Document.xh>
- #endif
-
- #ifndef _T_
- #error _T_ must be defined before including a .th file
- #endif
- #ifndef _C_
- #error _C_ must be defined before including a .th file
- #endif
-
- //===========================================================================
- // TempObj <T>
- //===========================================================================
-
- #ifdef _TMPL_IMPL_
-
- // Implementation of the TempRef constructor:
- _C_::_C_( _T_ *obj )
- {
- fObj = obj;
- }
-
- _C_::~_C_( )
- {
- // Prevent compiler from inlining synthesized destructor
- // which causes code bloat.
- }
-
- #else
-
- #if defined(__SC__) || defined(__MRC__)
- // Some of the typecasts below offend certain compilers.
- #pragma options(!warn_cast_incomplete_type)
- #endif
-
- // Declaration of the TempRef class
- class _C_ :public BaseTempRef
- {
- public:
- _C_( _T_* );
- virtual ~_C_( );
- _T_* operator-> () {return (_T_*)fObj;}
- operator _T_* () {return (_T_*)fObj;}
- _T_* operator=( _T_ *t ) {fObj=(ODRefCntObject*)t; return t;}
-
- _T_* DontRelease() {_T_* temp=(_T_*)fObj; fObj=kODNULL; return temp;}
- };
-
- #if defined(__SC__) || defined(__MRC__)
- #pragma options(warn_cast_incomplete_type) // undo previous pragma
- #endif
- #endif
-
- #undef _T_
- #undef _C_
-
-